<?php 
/**
 * Copyright (c) 2010, Slawomir Mazur <mazursllawek@gmail.com>
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions 
 * are met:
 * 
 * o Redistributions of source code must retain the above copyright notice, 
 *   this list of conditions and the following disclaimer.
 * o Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * o Neither the name of the Softisland nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/**
 * Enter description here...
 *
 * @package     Cms
 * @copyright   Slawomir Mazur (c) 2010 (http://www.zend.com/zce.php?c=ZEND011643)
 * @license     http://www.opensource.org/licenses/bsd-license.php
 * @author      Slawomir Mazur <mazursllawek@gmail.com>
 */
?>
<?php /* Initialize some heplers */ ?>
<?php $_companyHelper = $this->company() ?>
<?php $_libraryHelper = $this->library() ?>
<?php $_attributeHelper = $this->attribute() ?>
<?php $_year = $this->year ?>

<?php $user = $this->user()->getUser() ?>

<div class="container clear">
	<?php if (count($this->collection) > 0) : ?>
		<div id="multiquery-accordion">
		<div id="emptyValuesSwitcher" class="clear">
			<label><input type="checkbox" />Hide empty values</label>					
		</div>
		<?php foreach ($this->collection as $slideName => $collection) : ?>
			<?php $libraryId = -1; $iterator = 0; ?>
			<div class="multiquery-slice">
				<h3><?php echo $slideName ?></h3>
				<div class="q-content">
					
					<div class="gene-result-list clear">
					<?php if (($count = count($collection)) > 0) : ?>
						<?php $width = 100.0 / $count; $libraryId = -1; $iterator = 0; ?>
						<?php foreach ($collection as $arrayOfEntries) : if (0 == count($arrayOfEntries)) continue; ?>
							<div class="gene-result-list-library" style="width: <?php echo $width ?>%;">
								<h5>
									Library: <?php echo $name = $_companyHelper->getCompanyNameByLibraryId($arrayOfEntries[0]->library_id) ?>
									<strong>
										<small>
											[<?php echo $this->translate('RefSeq Annotation from') ?>&nbsp; 
											<label><?php echo $currentYear = $_libraryHelper->getLibraryCreatedDateById($arrayOfEntries[0]->library_id) ?></label>]
										</small>
									</strong>
									<strong>
										<small>
											<?php if ('' != ($provider = $_libraryHelper->getLibraryProviderById($arrayOfEntries[0]->library_id))) : ?>
												<a class="popup-link provider" href="<?php echo $provider ?>">[<?php echo $this->translate('Library design from') ?>&nbsp; 
												<label><?php echo $_libraryHelper->getLibraryDesignedDateById($arrayOfEntries[0]->library_id) ?></label>]</a>
											<?php else : ?>
												[<?php echo $this->translate('Library design from') ?>&nbsp; 
												<label><?php echo $_libraryHelper->getLibraryDesignedDateById($arrayOfEntries[0]->library_id) ?></label>]
											<?php endif ?>
										</small>
									</strong>
									<?php $companyId = $_companyHelper->getCompanyIdByLibraryId($arrayOfEntries[0]->library_id) ?>
									<small class="annotation-info"><?php echo $this->translate('Navigate to annotation for current<br />Gene and siRNA based on transcriptome') ?>:</small>
								</h5>
								<ol class="dater">
									<?php foreach ($this->library()->getAnnotationYears() as $year) : ?>
										<?php if ($year == $currentYear) continue; ?>
										<li><a href="<?php echo $this->baseUrl('index/library-history/cid/' . $companyId . '/q/' . $slideName . '/aid/' . $this->attributeId . '/year/' . $year) ?>"><span><em><?php echo $year ?></em></span></a></li>
									<?php endforeach ?>
								</ol>				
								<?php foreach ($arrayOfEntries as $historyEntry) : ?>
									<ul>
										<li class="start-item"></li>
										<?php foreach ($historyEntry as $code => $value) : ?>
											<?php if ($code == 'history_id' || $code == 'library_id') continue; ?>
											
											<?php $attributeName = $_attributeHelper->getAttributeNameByCode($code) ?>
											<?php $attributeValue = (empty($value))? '-' : $value ?>
											<li <?php if ('-' == $attributeValue) : ?>class="emptyvalue"<?php endif ?>>
											
												<?php echo $attributeName ?>:&nbsp;
												<span>
												<?php switch ($code) :
														case 'gene_symbol' : ?>
															<a href="<?php echo $this->baseUrl('index/network/gene/' . $attributeValue . '/library/' . $arrayOfEntries[0]->library_id) ?>" title="Known&amp;Predicted Off-target siRNA Interactions of <?php echo $attributeValue ?>"><?php echo $attributeValue ?><img alt="" width="60" class="network" src="<?php echo $this->baseUrl('skin/images/network.png') ?>" /></a>										
														<?php break ?>
														<?php case 'gene_id' : ?>
															<a class="popup-link" href="http://www.ncbi.nlm.nih.gov/gene/<?php echo $attributeValue ?>" title="NCBI library, Gene ID: <?php echo $attributeValue ?>"><?php echo $attributeValue ?></a>
														<?php break ?>
														<?php case 'sequence' : ?>
															<?php if ($user) : ?>
																<?php echo $attributeValue ?>
															<?php else : ?>
																<a class="blocked-data" href="<?php echo $this->baseUrl('user/auth/login') ?>">Login</a> or 
																<a class="blocked-data" href="<?php echo $this->baseUrl('index/contact') ?>">Contact us</a> to see this value
															<?php endif ?>
														<?php break ?>
														<?php default: ?>
															<?php echo $attributeValue ?>
														<?php break ?>
												<?php endswitch ?>
												</span>
											</li>
										<?php endforeach ?>
									</ul>
								<?php endforeach ?>
							</div>
						<?php endforeach ?>
					<?php endif ?>					
					</div>
				</div>
			</div>
		<?php endforeach ?>
		</div>
	<?php else : ?>
		<h5><?php echo $this->translate('No annotation founded in libraries from %s year for this value', $_year) ?></h5>
	<?php endif ?>
	<a class="back-link left" href="<?php echo $this->baseUrl('/') ?>" title="Go back">Back</a>	
</div>
<script type="text/javascript">
//<![CDATA[
	
//]]>
</script>